{extend name="common/base" /}
{block name="body"}
<style>
    .order-input{width:30px;text-align:center;}
    .layui-table td, .layui-table th {
        position: relative;
        padding: 9px 7px;
    }
</style>
<form action="" class="layui-form" method="get">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">标题：</label>
            <div class="layui-input-block">
                <input type="text" name="title" value="{$post.title}" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">类别：</label>
            <div class="layui-input-block">
                <select name="vote_type">
                    <option value="">不限</option>
                    <option value="1" {if $post.vote_type == 1}selected{/if}>少数派</option>
                    <option value="2" {if $post.vote_type == 2}selected{/if}>多数派</option>
                    <option value="3" {if $post.vote_type == 3}selected{/if}>预言帝</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">状态：</label>
            <div class="layui-input-block">
                <select name="vote_status">
                    <option value="">不限</option>
                    <option value="1" {if $post.vote_status == 1}selected{/if}>未开始</option>
                    <option value="2" {if $post.vote_status == 2}selected{/if}>进行中</option>
                    <option value="3" {if $post.vote_status == 3}selected{/if}>待开奖</option>
                    <option value="4" {if $post.vote_status == 4}selected{/if}>待结算</option>
                    <option value="5" {if $post.vote_status == 5}selected{/if}>已结算</option>
                </select>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn layui-btn-sm layui-btn-normal">
                    <i class="layui-icon">&#xe615;</i>
                    搜索</button>
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-block">
                <a href="{:url('guess_question/add')}" class="layui-btn layui-btn-sm layui-btn-normal"  >添加</a>
            </div>
        </div>
    </div>
</form>
<div>
    <form class="layui-form" action="" style="padding: 0px 10px 0px 10px;">
        <table class="layui-table" lay-skin="line">
            <colgroup>
                <col width="30px;">
                <col width="80px;">
                <col width="110px;">
                <col>
                <!--<col width="80px;">-->
                <col>
                <col>
                <col>
                <col width="60px;">
                <col width="60px;">
                <col width="60px;">
                <col width="140px;">
            </colgroup>
            <thead>
            <tr>
                <th>序号</th>
                <th>类型</th>
                <th>标题</th>
                <th>图片</th>
                <!--<th>金币池</th>-->
                <th>开始时间</th>
                <th>结束时间</th>
                <th>开奖时间</th>
                <th>状态</th>
                <th>评论</th>
                <th>选项</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {volist name="data" id="v"}
            <tr>
                <td><input class="order-input"
                           format-id="{$v.id}"
                           format-order-id="{$v.order_id}"
                           type="text"
                           value="{$v.order_id}"></td>
                <td>{$v.vote_type_desc}</td>
                <td title="{$v['title']}">{$v.title|mb_substr=0,30,'utf-8'}</td>
                <td>
                    <div  style="padding: 1px; border: #e6e6e6 solid 1px; width:35px; float: left; ">
                        <img class="form_logo" src="{$v.pic}" width="35" height="35">
                    </div>
                </td>
                <!--<td>{$v.coin_pool}</td>-->
                <td>{$v.start_time|date="Y-m-d H:i:s"}</td>
                <td>{$v.stop_time|date="Y-m-d H:i:s"}</td>
                <td>{$v.open_time|date="Y-m-d H:i:s"}</td>
                <td>{$v.is_settlement_desc}</td>
                <td>
                    <a href="{:url('comment/index',['type'=>'question','id'=>$v.id])}"
                       class="layui-btn layui-btn-sm layui-btn-normal">查看</a>
                </td>
                <td>
                    <a href="{:url('guess_option/index',['q_id'=>$v.id])}"
                       class="layui-btn layui-btn-sm layui-btn-normal">查看</a>
                </td>
                <td>
                    <a href="{:url('guess_question/edit',['id'=>$v.id])}"
                       class="layui-btn layui-btn-sm layui-btn-normal">修改</a>
                    <a href="javascript:;"
                       class="layui-btn layui-btn-sm layui-btn-danger" onclick="aa('{$v.id}')">删除</a>
                </td>
            </tr>
            {/volist}
            </tbody>
        </table>
    </form>
    {$page|raw}
</div>
<script>
    layui.use('laydate', function() {
        var laydate = layui.laydate;
        laydate.render({
            elem: '#rhaphp-time1'
            ,type: 'datetime'
            ,range: '到'
            ,format: 'yyyy-M-d'
        });
    })
    layui.use('form', function(){
        var $ = layui.jquery, form = layui.form;
    });
    // 排序
    $('.order-input').blur(function(){
        var id = $(this).attr('format-id');
        var order_id = $(this).val();
        var old_order_id = $(this).attr('format-order-id');
        if (old_order_id != order_id) {
            $.post("{:url('guess_question/saveOrderId')}",{id: id, order_id: order_id},function (res) {
                if(res.status=='0'){
                    layer.msg(res.msg);
                }
                if(res.status=='1'){
                    layer.msg(res.msg);
                }
            })
        }

    });
    function aa(id)
    {
        layer.confirm('确定删除吗？',{btn:['确定','取消']},function(res){
            $.post("{:url('guess_question/del')}",{id:id},function (res) {
                if(res.status=='0'){
                    layer.msg(res.msg);
                }
                if(res.status=='1'){
                    layer.msg(res.msg,{time:1000},function () {
                        location.href="{:url('guess_question/index')}";
                    });
                }
            })
        })

    }
    //删除
</script>
{/block}